package com.sl.hx.shop.http;

import com.sl.hx.shop.bean.AppStat;
import com.sl.hx.shop.bean.CentralNavigationList;
import com.sl.hx.shop.bean.CheckCollect;
import com.sl.hx.shop.bean.CollectList;
import com.sl.hx.shop.bean.FlashSaleList;
import com.sl.hx.shop.bean.GoodsClassify;
import com.sl.hx.shop.bean.HeadBean;
import com.sl.hx.shop.bean.HomeBannerBean;
import com.sl.hx.shop.bean.HomeGoodBuy;
import com.sl.hx.shop.bean.HomeRecommend;
import com.sl.hx.shop.bean.HotList;
import com.sl.hx.shop.bean.HotSearch;
import com.sl.hx.shop.bean.ImageUrlBean;
import com.sl.hx.shop.bean.LoginBean;
import com.sl.hx.shop.bean.MessageBean;
import com.sl.hx.shop.bean.NickName;
import com.sl.hx.shop.bean.ProductDetail;
import com.sl.hx.shop.bean.ProductList;
import com.sl.hx.shop.bean.RelationBean;
import com.sl.hx.shop.bean.SearchResult;
import com.sl.hx.shop.bean.ShopDetail;
import com.sl.hx.shop.bean.SpecialList;
import com.sl.hx.shop.bean.SplashBean;
import com.sl.hx.shop.bean.TokenBean;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Path;

/**
 * 所有的Api接口
 * <p>
 * Created by 王永琪 on 2018/10/20.
 */

public interface IApi {

    //单文件上传
    @Multipart
    @POST("file/upload")
    Observable<HttpResult<String>> upload(@Part MultipartBody.Part file);

    //多文件上传
    @Multipart
    @POST("file/multiUpload")
    Observable<HttpResult<List<String>>> multiUpload(@PartMap() Map<String, RequestBody> maps);

    //开屏页
    @GET("Api/index/getOpen")
    Observable<HttpResult<SplashBean>> getOpen ();

    //激活（获取token）
    @GET("Api/index/getToken/channel/{channel}")
    Observable<HttpResult<TokenBean>> getToken (@Path("channel") String channel);

    //版本开关接口
    @GET("Api/index/appstat/version/{version}/channel/{channel}")
    Observable<HttpResult<AppStat>> getAppstat (@Path("version")String version,
                                                @Path("channel") String channel);

    /*************************************登录*************************************/

    //获取验证码
    @FormUrlEncoded
    @POST("Api/regist/getCode")
    Observable<HttpResult<String>> getCode (@Field("phone")String phone,
                                            @Field("sign")String sign);

    //登录
    @FormUrlEncoded
    @POST("Api/regist/login")
    Observable<HttpResult<LoginBean>> login (@Field("phone")String phone,
                                             @Field("code")String code,
                                             @Field("channel")int channel,
                                             @Field("qudao")String qudao);

    /*************************************首页*************************************/

    //顶部banner
    @GET("Api/index/banner/layer/{layer}")
    Observable<HttpResult<List<HomeBannerBean>>> getBanner (@Header("Cache-Control") String cacheControl,
                                                            @Path("layer")String layer);

    //中部导航
    @GET("Api/index/banner/layer/{layer}")
    Observable<HttpResult<List<CentralNavigationList>>> getCentralNavigation (@Header("Cache-Control") String cacheControl,
                                                                              @Path("layer")String layer);

    //好惠买  1：热销爆款，2：热销排行榜，3：女装上新，4：限时抢购，5：9.9包邮专区
    @GET("Api/index/GoodBuy/type/{type}")
    Observable<HttpResult<HomeGoodBuy>> getGoodBuy(@Header("Cache-Control") String cacheControl,
                                                   @Path("type")int type);

    //今日推荐
    @GET("Api/index/recommend")
    Observable<HttpResult<List<HomeRecommend>>> getRecommend(@Header("Cache-Control") String cacheControl);

    //限时抢购页
    @GET("Api/index/flashSale/starttime/{starttime}/endtime/{endtime}/type/{type}/p/{p}/num/{num}")
    Observable<HttpResult<List<FlashSaleList>>> getFlashSale(@Header("Cache-Control") String cacheControl,
                                                             @Path("starttime")String starttime,
                                                             @Path("endtime")String endtime,
                                                             @Path("type")int type,
                                                             @Path("p")int page,
                                                             @Path("num")int num);

    //热销排行榜
    @GET("Api/index/rank")
    Observable<HttpResult<List<HotList>>> getHotList(@Header("Cache-Control") String cacheControl);


    //首页下方获取产品列表
    @GET("Api/index/productlist/favoritesid/{favoritesid}/type/{type}/p/{page}/num/{num}")
    Observable<HttpResult<List<ProductList>>> getProductList(@Header("Cache-Control") String cacheControl,
                                                             @Path("favoritesid")int favoritesid,
                                                             @Path("type")int type,
                                                             @Path("page")int page,
                                                             @Path("num")int num);

    //首页之外页面获取产品列表(选品库列表)
    @GET("Api/index/productlist/favoritesid/{favoritesid}/sort/{sort}/type/{type}/p/{page}/num/{num}")
    Observable<HttpResult<List<ProductList>>> getProductStoreList(@Path("favoritesid")int favoritesid,
                                                                  @Path("sort")int sort,
                                                                  @Path("type")int type,
                                                                  @Path("page")int page,
                                                                  @Path("num")int num);

    //专题页面
    @GET("Api/index/getSpecial")
    Observable<HttpResult<List<SpecialList>>> getSpecial(@Header("Cache-Control") String cacheControl);

    //获取产品详情
    @GET("Api/index/getProductDetail/num_iid/{num_id}/type/{type}")
    Observable<HttpResult<ProductDetail>> getProductDetail(@Header("Cache-Control") String cacheControl,
                                                           @Path("num_id")String num_id,
                                                           @Path("type")int type);

    //获取店铺详情
    @GET("Api/index/getshop/nick/{nick}/type/{type}")
    Observable<HttpResult<ShopDetail>> getShop(@Header("Cache-Control") String cacheControl,
                                               @Path("nick")String nick,
                                               @Path("type")int type);

    //收藏
    @FormUrlEncoded
    @POST("Api/my/writeCollect")
    Observable<HttpResult<String>> getWriteCollect(@Field("uid")String uid,
                                                   @Field("num_iid")String num_iid,
                                                   @Field("display")int display);

    //相关产品接口
    @GET("Api/index/relation/num_iid/{num_iid}/type/{type}")
    Observable<HttpResult<List<RelationBean>>> getRelation(@Header("Cache-Control") String cacheControl,
                                                           @Path("num_iid")String num_iid,
                                                           @Path("type")int type);

    /*************************************分类页*************************************/

    //商品类别
    @GET("Api/index/getCate")
    Observable<HttpResult<List<GoodsClassify>>> getCate(@Header("Cache-Control") String cacheControl);


    //分类页商品进入搜索
    @GET("Api/index/serch/title/{title}/sort/{sort}/type/{type}/p/{p}/num/{num}")
    Observable<HttpResult<List<SearchResult>>> getSearch(@Header("Cache-Control") String cacheControl,
                                                         @Path("title")String title,
                                                         @Path("sort")int sort,
                                                         @Path("type")int type,
                                                         @Path("p")int page,
                                                         @Path("num")int num);

    //热销排行fragment搜索
    @GET("Api/index/serch/title/{title}/type/{type}/p/{p}/num/{num}")
    Observable<HttpResult<List<SearchResult>>> getHomeSearch(@Path("title")String title,
                                                             @Path("type")int type,
                                                             @Path("p")int page,
                                                             @Path("num")int num);

    //热门搜索搜索
    @GET("Api/index/hotKey")
    Observable<HttpResult<List<HotSearch>>> getHotSearch(@Header("Cache-Control") String cacheControl);


    /*************************************收藏*************************************/

    //我的收藏
    @FormUrlEncoded
    @POST("Api/my/collectList/uid/{uid}")
    Observable<HttpResult<List<CollectList>>> getCollectList (@Field("uid")String uid,
                                                              @Field("p")int page,
                                                              @Field("num")int num);

    //删除收藏
    @FormUrlEncoded
    @POST("Api/my/delCollect")
    Observable<HttpResult<String>> delCollect (@Field("uid")String uid,
                                               @Field("num_iid")String num_iid);


    //查看商品是否被收藏
    @FormUrlEncoded
    @POST("Api/index/checkCollect")
    Observable<HttpResult<CheckCollect>> checkCollect (@Field("uid")String uid,
                                                       @Field("num_iid")String num_iid);

    /*************************************我的*************************************/

    //获取用户信息
    @FormUrlEncoded
    @POST("Api/my/myhead")
    Observable<HttpResult<HeadBean>> getMyhead (@Field("uid")String uid);


    //用户头像上传
    @Multipart
    @POST("Api/my/upload")
    Observable<HttpResult<ImageUrlBean>> headUpload (@Part("uid") RequestBody uid,
                                                     @Part MultipartBody.Part file);


    //修改昵称
    @FormUrlEncoded
    @POST("Api/my/nick")
    Observable<HttpResult<NickName>> getNick (@Field("uid")String uid,
                                              @Field("nick")String nick);


    //修改手机号
    @FormUrlEncoded
    @POST("Api/my/bindPhone")
    Observable<HttpResult<String>> bindPhone (@Field("uid")String uid,
                                              @Field("phone")String phone,
                                              @Field("code")String code);

    //消息通知
    @GET("Api/index/getMessage")
    Observable<HttpResult<List<MessageBean>>> getMessage(@Header("Cache-Control") String cacheControl);

    //意见反馈
    @FormUrlEncoded
    @POST("Api/index/feedback")
    Observable<HttpResult<String>> feedBack (@Field("uid")String uid,
                                             @Field("phone")String phone,
                                             @Field("content")String content);

    /*************************************统计*************************************/

    //首页内容统计
    @GET("Api/count/indexCount/layer/{layer}/tokenid/{tokenid}/cid/{cid}/channel/{channel}")
    Observable<HttpResult<String>> indexCount(@Path("layer")int layer,
                                              @Path("tokenid")int tokenid,
                                              @Path("cid")int cid,
                                              @Path("channel")String channel);

    //Tabar点击统计
    @GET("Api/count/buttonCount/type/{type}/tokenid/{tokenid}/channel/{channel}")
    Observable<HttpResult<String>> buttonCount(@Path("type")int type,
                                               @Path("tokenid")int tokenid,
                                               @Path("channel")String channel);

    //商品购买统计
    @GET("Api/count/productCount/type/{type}/tokenid/{tokenid}/channel/{channel}")
    Observable<HttpResult<String>> productCount(@Path("type")int type,
                                                @Path("tokenid")int tokenid,
                                                @Path("channel")String channel);

}
